package com.youlemall.shop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.youlemall.pojo.Seller;
import com.youlemall.service.SellerService;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 2 * @Author: kevin
 * 3 * @Date: 2019/7/18 17:35
 * 4
 */
@RestController
@RequestMapping("/seller")
public class SellerController {

	@Reference(timeout = 10000)
	private SellerService sellerService;

	@PostMapping("/save")
	public boolean save(@RequestBody Seller seller){
		try {
			String password = new SimpleHash("md5", seller.getPassword(),
					seller.getSellerId(), 5).toHex();
			seller.setPassword(password);
			sellerService.save(seller);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
}
